#include <iostream>
using namespace std;

/*
    研究系统提供的拷贝构造函数究竟做了什么
      Cat(const Cat &other)  //系统提供的拷贝构造函数
      {
          this->name = other.name;
          this->age = other.age;
          this->weight = other.weight;
      }
      Cat c2=c1; //调用上面系统提供的拷贝构造函数
                  //编译器这句话理解成了
                    Cat(c1)  c2是当前对象，c1是实参
*/

class Cat
{
public:
    Cat(string name, int age, float weight)
    {
        this->name = name;
        this->age = age;
        this->weight = weight;
        cout << "有参构造函数" << endl;
    }
    Cat()
    {
        cout << "无参构造函数" << endl;
    }

    void show()
    {
        cout << "name:" << name << endl;
        cout << "age:" << age << endl;
        cout << "weight:" << weight << endl;
    }

private:
    string name;
    int age;
    float weight;
};

int main()
{
    // 创建猫对象
    Cat c1("旺财", 5, 15.5);

    Cat c2 = c1; // 调用拷贝构造函数
    c2.show();
    return 0;
}
